#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
import socket

c = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

c.settimeout(1)

c.connect_ex(("111.225.221.136", 23456))
# print(c)
if c == 0:
    print("ok")


sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# myname = socket.getfqdn("gk.vp.cn")
# myaddr = socket.gethostbyname(myname)         # 将主机名解析成地址
# print(myaddr)# sock.settimeout(1)

# x = socket.gethostbyaddr("recv.vp.cn")
# print(x)
socket.timeout(1)
result = sock.connect_ex(('192.168.9.5', 80))
if result == 0:
    print("Port %d is open" % 80)
else:
    print("Port %d is not open" % 80)
sock.close()
